package bist.believeinstep.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bist.believeinstep.domain.RestaurantHotel;
import bist.believeinstep.util.Constant.RSType;
import bist.believeinstep.util.Constant.Rate;
import bist.believeinstep.util.Constant.State;

public class RestaurantHotelMapper implements RowMapper<RestaurantHotel> {
	public RestaurantHotel mapRow(ResultSet rs, int rowNum) throws SQLException{
		RestaurantHotel restaurantHotel = new RestaurantHotel();
		
		restaurantHotel.setId(rs.getInt("id"));
		restaurantHotel.setName(rs.getString("name"));
		restaurantHotel.setAvatar(rs.getString("avatar"));
		restaurantHotel.setPhone(rs.getString("phone"));
		restaurantHotel.setEmail(rs.getString("email"));
		restaurantHotel.setAddress(rs.getString("address"));
		restaurantHotel.setAddress1(rs.getString("address1"));
		restaurantHotel.setAddress2(rs.getString("address2"));
		
		String state = rs.getString("state");
		restaurantHotel.setState(State.create(state));
		
		restaurantHotel.setStar(rs.getInt("star"));
		restaurantHotel.setDescription(rs.getString("descriptions"));
		
		String rate = rs.getString("rate");
		restaurantHotel.setRate(Rate.create(rate));
		
		String type = rs.getString("type");
		restaurantHotel.setType(RSType.create(type));
		
		restaurantHotel.setCreated(rs.getTimestamp("created_date"));
		restaurantHotel.setModified(rs.getTimestamp("modified_date"));
		restaurantHotel.setCreatedBy(rs.getString("created_by"));
		restaurantHotel.setModifiedBy(rs.getString("modified_by"));
		
		return restaurantHotel;
	}
}
